<template>
	<view>
		<view class="ceiling" :style="{ 'padding-top': statusBarHeight + 'px' }"></view>
		<!-- 顶部导航 开始 -->
		<selectHead left-button="转入" right-button="转出" class="selectBox" :active-button="activeButton" @changeBtn="handleSelect">
			<view slot="left" @click="toHome()">
				<view class="" style="color: #FFFFFF;">主页</view>
			</view>
			<view slot="right">
				<view class="flex align-center" style="position: relative;">
					<view class="Tips end_top margin-left-xs" @click="tonavigateTo('/pages/public/search/search')" style="margin-right: 5rpx;position: absolute;left: -72rpx;">
						<image src="/static/images/search.png" mode="widthFix" style="width: 50rpx;"></image>
					</view>
					<view class="Tips end_top margin-left-xs" @click="tonavigateTo('/pages/public/msg/msg')">
						<image src="/static/images/msg.png" mode="widthFix" style="width: 50rpx;"></image>
					</view>
				</view>
			</view>
		</selectHead>
		<!-- 顶部导航 结束 -->

		
		<view v-if="activeButton == '转入'">
			<view class="flex justify-between align-center border-bottom-1B202C padding" v-for="(item,index) in dataRecharge" :key="index">
				<view>
					<view class="text-lg text-green">状态：{{item.statusName}}</view>
					<view class="text-sm color_99A2B5 margin-top-sm" v-if="item.ucardno !=null">卡号：{{item.ucardno.substring(0,4)}} **** **** {{item.ucardno.split("").reverse().join("").substring(0,4).split("").reverse().join("")}}</view>
				</view>
				<view>
					<view class="text-black text-lg text-right">金额：{{parseFloat(item.money).toFixed(2)}}元</view>
					<view class="text-sm color_99A2B5 margin-top-sm text-right">{{item.atime}}</view>
				</view>
			</view>
		</view>
		
		<view v-if="activeButton == '转出'">
			<view class="flex justify-between align-center border-bottom-1B202C padding" v-for="(item,index) in dataCash" :key="index" >
				<view>
					<view class="text-lg text-green">状态：{{item.statusName}}</view>
					<view class="text-sm color_99A2B5 margin-top-sm">卡号：{{item.cardno.substring(0,4)}} **** **** {{item.cardno.split("").reverse().join("").substring(0,4).split("").reverse().join("")}}</view>
				</view>
				<view>
					<view class="text-black text-lg text-right">金额：{{parseFloat(item.money).toFixed(2)}}元</view>
					<view class="text-sm color_99A2B5 margin-top-sm text-right">{{item.atime}}</view>
				</view>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	import selectHead from "@/component/selectHead/selectHead.vue"
	export default {
		components: {
			selectHead
		},
		data() {
			return {
				activeButton: "转入", //传入选中的button
				statusBarHeight: getApp().globalData.statusBarHeight, //状态栏高度
				
				dataRecharge: [],
				dataCash: [],
			}
		},
		methods: {
			// 跳转页面
			tonavigateTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 到首页
			toHome: function() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			//返回上一页
			handleBack(){
				uni.navigateBack({
				    delta: 1
				});
			},
			//选择行情/自选
			handleSelect(type) {
				this.activeButton = type == 'left' ? '转入' : '转出'
			},
			// 转入
			getRecharge(){
				this.$Request.get(this.$api.index.getRecharge).then(res => {
					this.dataRecharge = res.data;
				})
			},
			// 转出
			getCash(){
				this.$Request.get(this.$api.index.getCash).then(res => {
					this.dataCash = res.data;
				})
			},
		},
		onLoad(e) {
			if(e.type == 2){
				this.activeButton = '转出'
			}
			this.getRecharge()
			this.getCash()
		}
	}
</script>
<style scoped>
	.selectBox{
		background-color: #EE515A;
	}
	.border-bottom-1B202C{
		border-color: #DDDDDD;
	}
</style>
